import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// const { createProxyMiddleware } = require('http-proxy-middleware');

// https://vite.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    vueDevTools(),
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
  server: {
    proxy: {
      '/socket.io': {
        target: 'ws://localhost:7778',
        ws: true,
        rewriteWsOrigin: true,
      },
      '/list_agent': {
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/down_me/':{
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/down_results':{
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/del_agent':{
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/get_batch':{
        target: 'http://localhost:7777',
        changeOrigin: true,
      },
      '/login': {
        target: 'http://localhost:7777',
        changeOrigin: true,
      },
      '/register': {
        target: 'http://localhost:7777',
        changeOrigin: true,
      },
      '/get_preview': {
        target: 'http://localhost:7778',
        changeOrigin: true,
        pathRewrite: { '^/get_preview': '/get_preview' },
        
      },
      '/get_sessions': {
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/save_session': {
        target: 'http://localhost:7778',
        changeOrigin: true,
      },
      '/save_agent': {
        target: 'http://localhost:7778',
        changeOrigin: true,
        pathRewrite: { '^/save_agent': '/save_agent' },
        
      },
      '/load_agent': {
        target: 'http://localhost:7778',
        changeOrigin: true,
        pathRewrite: { '^/load_agent': '/load_agent' },
        
      },
     
      '/upload':{
        target: 'http://localhost:7778',
        changeOrigin: true,
      },

      '/v1/chat/completions':{
        target: 'http://localhost:7778',
        changeOrigin: true,
      
      }

    },
  },
  
  
})


